import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:leader_help/page/task/subs/question_detail/index.dart';
import 'package:leader_help/utils/component/dialog/drop.dart';
import 'package:leader_help/utils/util.dart';

import 'cell_empty.dart';

class QuestionDetailProgressCell extends GetView<QuestionDetailController> {
  const QuestionDetailProgressCell({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return GetBuilder<QuestionDetailController>(
      builder: (_) {
        var mod = controller.state.taskMod;
        return mod == null
            ? QuestionDetailEmptyView(
                mod: UsuallyModel(
                    name: '暂无最新进展', url: 'progress_bg.png'.imgPathTask),
              )
            : Container(
                child: Column(
                  children: [
                    _getItem(
                      name: '省财政厅',
                      title: '执行方案中，已逾期',
                      content: '省财政厅牵头，目前已解决60家企业的资本要素问题。原计划4月25日完成，剩余25家未完成。',
                      date: '2022-04-25',
                    ),
                    _getItem(
                      name: '省财政厅',
                      title: '牵头制定针对性执行方案',
                      content: '省财政厅根据任务和要求，牵头制定针对94家企业的资本配置提高方案。',
                      date: '2022-02-18',
                      isFinish: true,
                    ),
                    _getItem(
                      name: '办公厅',
                      title: '完成工作安排交办',
                      content: '办公厅XX将此项安排召开会议交办给省财政厅及其他各部门',
                      date: '2022-02-11',
                      isFinish: true,
                    ),
                  ],
                ),
              );
      },
    );
  }

  Widget _getItem({
    required String name,
    required String title,
    required String content,
    required String date,
    bool? isFinish,
  }) {
    return Row(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        _getCircleText(title: name, isFinish: isFinish),
        SizedBox(
          width: 10.r,
        ),
        Expanded(
          child: Column(
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(
                    title,
                    style: pfMediumStyle(
                        color: isFinish == true
                            ? ColorsUtil.title
                            : ColorsUtil.red,
                        fontSize: 15.sp),
                  ),
                  Text(
                    date,
                    style: pfMediumStyle(
                        color: ColorsUtil.content, fontSize: 13.sp),
                  ),
                ],
              ),
              Text(
                content,
                style:
                    pfMediumStyle(color: ColorsUtil.content, fontSize: 14.sp),
              ),
              Container(
                margin: EdgeInsets.symmetric(vertical: 10.r),
                color: ColorsUtil.separator,
                height: 0.5,
                width: Get.width,
              )
            ],
          ),
        ),
      ],
    );
  }

  Widget _getCircleText({
    required String title,
    bool? isFinish,
  }) {
    return Stack(
      children: [
        Container(
          width: 56.r,
          height: 56.r,
          alignment: Alignment.center,
          decoration: BoxDecoration(
            color: ColorsUtil.bg,
            borderRadius: BorderRadius.circular(28.r),
          ),
          child: Text(
            title,
            textAlign: TextAlign.center,
            style: pfMediumStyle(color: ColorsUtil.title, fontSize: 14.sp),
          ),
        ),
        Positioned(
          bottom: 0,
          right: 0,
          child: Icon(isFinish == true ? Icons.check_circle : Icons.info,
              color: isFinish == true ? ColorsUtil.green : ColorsUtil.red,
              size: 20.r),
        ),
      ],
    );
  }
}
